package com.calc;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.*;

public class CalculatriceActivity extends Activity {
	
	protected Integer num1;
	protected Integer num2;
	protected Integer answer;
	protected char opperator;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        //FINDVIEWBYID
        
        Button btn0 = (Button)findViewById(R.id.btn0);
        Button btn1 = (Button)findViewById(R.id.btn1);
        Button btn2 = (Button)findViewById(R.id.btn2);
        Button btn3 = (Button)findViewById(R.id.btn3);
        Button btn4 = (Button)findViewById(R.id.btn4);
        Button btn5 = (Button)findViewById(R.id.btn5);
        Button btn6 = (Button)findViewById(R.id.btn6);
        Button btn7 = (Button)findViewById(R.id.btn7);
        Button btn8 = (Button)findViewById(R.id.btn8);
        Button btn9 = (Button)findViewById(R.id.btn9);
        Button btn12 = (Button)findViewById(R.id.btn12);
        Button btn14 = (Button)findViewById(R.id.btn14);
        EditText box = (EditText)findViewById(R.id.box);
        
        //OPPERATIONS
        
        
        
        //ON CLICK LISTENERS
        
        btn14.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				num2 = Integer.getInteger(box.getText().toString());
        				System.out.println("fdwa");
        				System.out.println(num1.toString());
        				System.out.println(num2.toString());
        				System.out.println(opperator);
        				if(opperator == '+'){
        					answer = num1 + num2;
        					box.setText(answer.toString());
        				}
        			}
        		});
        
        btn12.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				num1 = Double.getInteger(box.getText().toString());
        				System.out.println(num1);
        				box.setText("");
        				opperator = '+';
        			}
        		});
        
        btn0.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"0");
        			}
        		});
        
        btn1.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"1");
        				
					}
        		});
        				
        btn2.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"2");
        			}
        		});
        
        btn3.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"3");
        			}
        		});
        
        btn4.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"4");
        			}
        		});
        
        btn5.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"5");
        			}
        		});
        
        btn6.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"6");
        			}
        		});
        
        btn7.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"7");
        			}
        		});
        
        btn8.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"8");
        			}
        		});
        
        btn9.setOnClickListener(
        		new OnClickListener(){
        			public void onClick(View v){
        				EditText box = (EditText)findViewById(R.id.box);
        				box.setText(box.getText()+"9");
        			}
        		});
						

    }
}